requirejs.config({
    baseUrl: 'js',
    paths: {
        'knockout': 'libs/knockout/knockout-3.4.0.debug',
        'jquery': 'libs/jquery/jquery-3.1.0',
        'jqueryui-amd': 'libs/jquery/jqueryui-amd-1.12.0',
        'promise': 'libs/es6-promise/es6-promise',
        'hammerjs': 'libs/hammer/hammer-2.0.8',
        'ojdnd': 'libs/dnd-polyfill/dnd-polyfill-1.0.0',
        'ojs': 'libs/oj/v2.2.0/debug',
        'ojL10n': 'libs/oj/v2.2.0/ojL10n',
        'ojtranslations': 'libs/oj/v2.2.0/resources',
        'text': 'libs/require/text',
        'signals': 'libs/js-signals/signals'
    },
    shim: {
        'jquery': {
            exports: ['jQuery', '$']
        }
    }
});

require(['ojs/ojcore', 'knockout', 'jquery', 'ojs/ojknockout', 'ojs/ojtable', 'ojs/ojpagingcontrol', 'ojs/ojpagingtabledatasource', 'ojs/ojarraytabledatasource'],
    function(oj, ko, $) {
        $(function() {
            function init() {
                $('#updataVerson').text('beta 1.0.6');
                $('#updataTime').text('2016/12/23');
                var num1 = 0;
                var num2 = 0;
                $('.navList').find('li').not('.resourceList').click(function() {
                    $('.navList').find('li').removeClass('active');
                    $(this).addClass('active');
                })
                $('.resourceList').find('div').click(function() {
                    num2 += 180;
                    if ($('.resource').css('display') == "none") {
                        $('.resource').slideDown();
                    } else {
                        $('.resource').slideUp();
                    }
                    $(this).next('.triangle').css({
                        'transform': 'rotate(' + num2 + 'deg)',
                        'transition': '1s',
                    })
                })
                var data = ["home", "servelist", "playbook", "review"];
                var viewModel = {
                    val: ko.observable(data[3])
                }
                ko.applyBindings(viewModel, document.getElementById('content'));
                $('.routerList').click(function() {
                    var _index = $(this).index('.routerList');
                    viewModel.val(data[_index]);
                    /*if (_index == 0) {
                        window.location.href =$('base').attr('href')+'#';
                    }else{
                        window.location.href = $('base').attr('href') +"#"+data[_index];
                    }*/
                });
            }
            if ($(document.body).hasClass('oj-hybrid')) {
                document.addEventListener("deviceready", init);
            } else {
                init();
            }
        });
    }
);

require(['ojs/ojcore', 'knockout', 'jquery', 'ojs/ojknockout',
        'ojs/ojmodule', 'ojs/ojrouter', 'ojs/ojnavigationlist',
        'ojs/ojjsontreedatasource', 'text'
    ],
    function(oj, ko, $) {
        oj.ModuleBinding.defaults.modelPath = 'viewModels/';
        oj.ModuleBinding.defaults.viewPath = 'text!views/';
    }
);
